import Vue from 'vue'
import Vuex from 'vuex'
import {getLogin} from '../api/login'
import { GET_USERUNFO } from './mutation-type'

Vue.use(Vuex)
export default new Vuex.Store({
    state:{
        userInfo:{},
        roles:{}
    },
    mutations:{
        [GET_USERUNFO](state,obj){
            state.userInfo=obj
        },
        GET_ROLES:(state,obj)=>{
            state.roles=obj
        },
    },
    actions:{
        async getLogin({commit},obj){
            let userInfo =await getLogin(obj)
            commit("GET_USERUNFO", userInfo.data)
            
        }
    }
})